package com.ITD.controller;

import com.ITD.pojo.NewEvent;
import com.ITD.pojo.QuerySumParam;
import com.ITD.pojo.QueryWorkParam;
import com.ITD.service.EventService;
import com.ITD.service.StudentService;
import com.ITD.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags="事件导入")
@RestController
@RequestMapping("/moral/event")
public class EventController {
    @Autowired
    RedisTemplate<String, String> redisTemplate;
    @Autowired
    EventService eventService;
    @Autowired
    StudentService studentService;


   @ApiOperation("导入新事件")
   @PostMapping(value ="/new")
    public Result importNew(NewEvent newEvent, @RequestHeader("Authorization")String authorization){
       System.out.println(newEvent);

       return eventService.insertNewEvent(newEvent, authorization);
       //return Result.success(event.getScore());
    }


    @ApiOperation("查询事件")
    @PostMapping("/grade_event")
    public Result QueryEvent(QueryWorkParam queryWorkParam, @RequestHeader("Authorization")String authorization){

        return eventService.queryEvents(queryWorkParam, authorization);

    }
    @ApiOperation("统计事件")
    @PostMapping(value ="/sumup")
    public Result sumEvents(QuerySumParam querySumParam){

       return eventService.sumEvents(querySumParam);
    }
    @ApiOperation("录入预览学生姓名")
    @PostMapping(value ="/check")
    public Result check(String stuno){
        return eventService.check(stuno);
    }
    @ApiOperation("导出excel")
    @PostMapping(value ="/export_grade_event")
    public void exportExcel(){
        eventService.exportExcel();
    }
}
